//
//  CommonView.m
//  BGM
//
//  Created by liuqin on 2018/11/28.
//  Copyright © 2018年 com.alirtc.demo. All rights reserved.
//

#import "CommonView.h"

@implementation CommonView


+(UIAlertController *)getCommonAlert:(NSString *)title message:(NSString *)message ok:(NSString *)Ok cancel:(NSString *)cancel completed:(void(^)(NSInteger index))completion{
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:title
                                                                   message:message
                                                            preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:Ok style:UIAlertActionStyleDefault
                                                          handler:^(UIAlertAction * action) {
                                                              //响应事件
                                                              if(completion){
                                                                  completion(1);
                                                              }
                                                          }];
    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:cancel style:UIAlertActionStyleDefault
                                                         handler:^(UIAlertAction * action) {
                                                             //响应事件
                                                             if(completion){
                                                                 completion(0);
                                                             }
                                                             
                                                         }];
    
    [alert addAction:defaultAction];
    [alert addAction:cancelAction];
    return alert;
    //    [self presentViewController:alert animated:YES completion:nil];
}




@end
